package util.core;

import java.io.File;
import java.io.IOException;

/**
 * Created by WhiteBlue on 15/5/11.
 */
public class FileManager {


    public static void deleteDirs(File dir) {
        if (dir.isDirectory()) {
            String[] children = dir.list();
            for (int i = 0; i < children.length; i++) {
                deleteDirs(new File(dir, children[i]));
            }
        }
        dir.delete();
    }


    public static boolean moveFile(File file, String path) throws IOException {
        File dir = new File(path);
        dir.mkdir();
        File new_file = new File(path + "/"+ file.getName());
        if (file.renameTo(new_file))
            return true;
        else
            return false;
    }


    public static File getFile(String name,String path) {
        File file = new File(path+ File.pathSeparator+name);
        if (file.exists())
            return file;
        else
            return null;
    }


}
